<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateUserFinance extends Migrator
{
    public function up()
    {
        $table = $this->table('user_finance',['signed' =>false,'comment'=>'金融产品表']);
        $table->addColumn('user_id','integer',['limit'=>10,'comment'=>'用户id'])
            ->addForeignKey('user_id', 'user', 'id', ['delete'=> 'CASCADE'])
            ->addColumn('unit_name','string',['limit'=>120,'default'=>'','comment'=>'单位名称'])
            ->addColumn('identify_num','string',['limit'=>32,'default'=>'','comment'=>'识别号'])
            ->addColumn('register_address','string',['limit'=>255,'default'=>0,'comment'=>'注册地址'])
            ->addColumn('register_phone','string',['limit'=>11,'default'=>'','comment'=>'注册电话'])
            ->addColumn('bank_id','integer',['limit'=>10,'comment'=>'开户银行id'])
            ->addForeignKey('bank_id', 'bank', 'id', ['delete'=> 'CASCADE'])
            ->addColumn('bank_number','string',['limit'=>25,'comment'=>'银行卡号'])
            ->addColumn('create_time','integer',['limit'=>10,'default'=>0,'comment'=>'创建时间'])
            ->addColumn('update_time','integer',['limit'=>10,'default'=>0,'comment'=>'修改时间'])
            ->create();
    }

    public function down()
    {
        $this->dropTable('finance');
    }
}
